import ssh
import nodes
import measure_pull
import renderer

username='usf_ubcslice5'
keyfile='/home/.ssh/id_rsa'
hostnames = nodes.get_hostnames()

#hostnames = ['planetlab4.cs.uiuc.edu', 'lefthand.eecs.harvard.edu']

stats = {}
for host in hostnames:
	disk = ssh.command('df -P', 'eece411', username, keyfile, host)
	if disk == 'None':
		stat = {'loginable':'No'}
		stats[host] = stat
		continue
	disk = measure_pull.disk_space(disk)

	uptime = ssh.command('uptime', 'eece411', username, keyfile, host)
	uptime = measure_pull.uptime(uptime)
	cpu_load = measure_pull.cpu_load(uptime)

	#cores_info = ssh.command('grep "cpu cores" /proc/cpuinfo', 'eece411', username, keyfile, host)
	#cores_info = yanm.num_cores(cores_info)

	cpu_info = ssh.command('grep "processor" /proc/cpuinfo', 'eece411', username, keyfile, host)
	cpu_info = measure_pull.num_cpus(cpu_info)

	#freq_info = ssh.command('grep "cpu MHz" /proc/cpuinfo', 'eece411', username, keyfile, host)
	#freq_info = yanm.avg_cpu_freq(freq_info)

	#boot_time = ssh.command('who -b', 'eece411', username, keyfile, host)
	#boot_time = yanm.boot_time(boot_time)

	#mem_info = ssh.command('free -m', 'eece411', username, keyfile, host)
	#mem_info = measure_pull.memory(mem_info)

	#java_info = ssh.command('java -version', 'eece411', username, keyfile, host)
	#java_info = measure_pull.java(java_info)

	stat = {'booted':'Yes',
		'loginable':'Yes',
		'disk':disk,
		'uptime':uptime,
		'cpu_load':cpu_load,
		#'num_cores':cores_info,
		'num_cpus':cpu_info}
		#'avg_cpu_freq':freq_info,
		#'boot_time':boot_time,
		#'memory':mem_inf,
		#'java':java_info}
	stats[host] = stat
	print stats

renderer.render(stats)